package com.hundsun.yr.universal.p2p.bean;

import android.text.TextUtils;

/**
 * 借款获取预计收益
 * 
 * @author tonglj
 * 
 */
public class LoanParam extends BaseParam {
	/**
	 * 
	 */
	private static final long serialVersionUID = -1923125980149351358L;
	public final static String DAY = "DAY";
	public final static String MONTH = "MONTH";
	/**
	 * 借款金额
	 */
	private double borrowAmount;
	/**
	 * 借款期限单位
	 */
	private String borrowPeriodUnit;
	/**
	 * 借款期限
	 */
	private int borrowPeriod;
	/**
	 * 加点利率(必需)
	 */
	private double incrementRate;
	/**
	 * 还款利率
	 */
	private double rate;
//	/**
//	 * 操作人
//	 */
//	private String operator;
	/**
	 * 外部流水号
	 */
	private String outSerialId;
	/**
	 * 产品ID
	 */
	private String productId;
	/**
	 * 产品名称
	 */
	private String productName;
	/**
	 * 协议id
	 */
	private String protocolId;
	/**
	 * 募集期限
	 */
	private int raisePeriodLimit;
	/**
	 * 还款方式
	 */
	private String refundWay;
	/**
	 * 借款用途
	 */
	private String loanUse;
	/**
	 * 审核周期
	 */
	private int checkPeriod;
	/**
	 * 借款时间
	 */
	private long loanTime;
	/**
	 * 获取借款天数
	 * @return
	 */
	public int getLoanDays(){
//		if(DAY.equals(borrowPeriodUnit)){
//			return borrowPeriod;
//		}else if(MONTH.equals(borrowPeriodUnit)){
//			return borrowPeriod * 30;
//		}
		if(TextUtils.equals(refundWay, "MONTH_AMT")){
			return borrowPeriod * 30;
		}else{
			return borrowPeriod;
		}
	}
	

	@Override
	public boolean checkInfo() {
		
		
		if(borrowAmount ==  0){
			return false;
		}else if(borrowPeriod == 0){
			return false;
		}
		else if(incrementRate == -1){
			return false;
		}
		else if(raisePeriodLimit == 0){
			return false; 
		}else if(TextUtils.isEmpty(refundWay)){
			return false; 
		}else if(TextUtils.isEmpty(loanUse)){
			return false;
		}
		return true;
	}

	public String getBorrowPeriodUnit() {
		return borrowPeriodUnit;
	}

	public void setBorrowPeriodUnit(String borrowPeriodUnit) {
		this.borrowPeriodUnit = borrowPeriodUnit;
	}

	public double getBorrowAmount() {
		return borrowAmount;
	}

	public void setBorrowAmount(double borrowAmount) {
		this.borrowAmount = borrowAmount;
	}

	public double getIncrementRate() {
		return incrementRate;
	}

	public void setIncrementRate(double incrementRate) {
		this.incrementRate = incrementRate;
	}

//	public String getOperator() {
//		return operator;
//	}
//
//	public void setOperator(String operator) {
//		this.operator = operator;
//	}

	public double getRate() {
		return rate;
	}

	public void setRate(double rate) {
		this.rate = rate;
	}

	public String getOutSerialId() {
		return outSerialId;
	}

	public void setOutSerialId(String outSerialId) {
		this.outSerialId = outSerialId;
	}

	public String getProductId() {
		return productId;
	}

	public void setProductId(String productId) {
		this.productId = productId;
	}

	public String getProductName() {
		return productName;
	}

	public void setProductName(String productName) {
		this.productName = productName;
	}

	public String getProtocolId() {
		return protocolId;
	}

	public void setProtocolId(String protocolId) {
		this.protocolId = protocolId;
	}

	public int getRaisePeriodLimit() {
		return raisePeriodLimit;
	}

	public void setRaisePeriodLimit(int raisePeriodLimit) {
		this.raisePeriodLimit = raisePeriodLimit;
	}

	public String getRefundWay() {
		return refundWay;
	}

	public void setRefundWay(String refundWay) {
		this.refundWay = refundWay;
	}

	public String getLoanUse() {
		return loanUse;
	}

	public void setLoanUse(String loanUse) {
		this.loanUse = loanUse;
	}

	public int getBorrowPeriod() {
		return borrowPeriod;
	}

	public void setBorrowPeriod(int borrowPeriod) {
		this.borrowPeriod = borrowPeriod;
	}

	public int getCheckPeriod() {
		return checkPeriod;
	}

	public void setCheckPeriod(int checkPeriod) {
		this.checkPeriod = checkPeriod;
	}

	public long getLoanTime() {
		return loanTime;
	}

	public void setLoanTime(long loanTime) {
		this.loanTime = loanTime;
	}
	

	/**
	 * 显示还款方式
	 */
	public String displayReturnWay(){
		if("ONCE_TIME".equals(refundWay)){
			return "到期还本付息";
		}else if("PROFIT_PRINCIPAL".equals(refundWay)){
			return "先息后本";
		}else if("MONTH_AMT".equals(refundWay)){
			return "等额本息";
		}
		return "";	
	}
	/**
	 * 显示时间单位
	 * @return
	 */
	public String displayTermUnit(){
		if(MONTH.equals(borrowPeriodUnit)){
			return "月";	
		}else if(DAY.equals(borrowPeriodUnit)){
			return "天";	
		}
		return "天";	
	}
}
